﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GOAP.Entities
{

    using ConnectionType = List<string>;

    class Node : Entity
    {
        protected ConnectionType connections;

        public Node()
        {
            connections = new ConnectionType();
        }

        public void addConnection(Node target)
        {
            //Make connection 2-way. Avoid inf loop
            if (!connections.Contains(target.name))
            {
                connections.Add(target.name);
                target.addConnection(this);
            }
        }

        public ConnectionType getConnections()
        {
            return connections;
        }

        override public void copyMembers(Entity copy)
        {
            base.copyMembers(copy);
            Node n = copy as Node;
            n.connections = new ConnectionType(connections);
        }

        override public Entity clone()
        {
            Node copy = new Node();
            copyMembers(copy);
            return copy;
        } 
    }
}
